<!DOCTYPE html>
<html lang="zh-CN">
    <head>
        <meta charset="UTF-8" />
        <title>21_案例练习-鼠标跟随移动</title>
        <style>
            * {
                margin: 0;
                padding: 0;
            }

            img {
                position: absolute;
                left: 0;
                top: 0;

                width: 200px;
                height: 200px;
            }
        </style>
    </head>
    <body>
        <img src="./img/1.jpg">

        <script>

            var img = document.querySelector('img');

            document.onmousemove = function(event){
                img.style.left = event.clientX + 'px';
                img.style.top = event.clientY + 'px';
            }
        </script>
    </body>
</html>